/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#include "MapDatabase.h"
#include "MapDbc.h"
#include "WOWArchive.h"

namespace PQGameCore
{
	WdtFile* MapDatabase::getWdtFile(int index)
	{
		MapInfo info=SMapDbc.getMapInfo(index);

		char filename[256];
		sprintf(filename,"World\\Maps\\%s\\%s.wdt", info.Name.c_str(),  info.Name.c_str());
		
		MPQFile* f=SWOWArchive.openMPQFile(filename);
		WdtFile* wdt=new WdtFile();
		wdt->init(f);
		return wdt;
	}

	WdlFile* MapDatabase::getWdlFile(int index)
	{
		MapInfo info=SMapDbc.getMapInfo(index);

		char filename[256];
		sprintf(filename,"World\\Maps\\%s\\%s.wdl", info.Name.c_str(),  info.Name.c_str());

		MPQFile* f=SWOWArchive.openMPQFile(filename);
		WdlFile* wdl=new WdlFile();
		wdl->init(f);
		return wdl;//should we keep a easy search pointer?
	}
}
